package com.viewmode1;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.viewmode1.databinding.ActivityDataBindBinding;


public class DataBindActivity extends AppCompatActivity {
    DataBindViewModel viewModel;
//    TextView textView;
//    Button button;
    ActivityDataBindBinding bindBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_data_bind);
        bindBinding = DataBindingUtil.setContentView(this,R.layout.activity_data_bind);

        viewModel = ViewModelProviders.of(this).get(DataBindViewModel.class);
//        textView = findViewById(R.id.textView2);
//        button = findViewById(R.id.button3);
//        viewModel.getNumber().observe(this, new Observer<Integer>() {
//            @Override
//            public void onChanged(Integer integer) {
//                bindBinding.textView2.setText(""+integer);
//            }
//        });
        bindBinding.setData(viewModel);
        bindBinding.setLifecycleOwner(this);
//        bindBinding.button3.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                viewModel.addValue();
//            }
//        });
    }
}
